import { IPSDEGroupDetail } from './ipsdegroup-detail';
import { IPSSysDEGroup } from './ipssys-degroup';
import { IPSSysSFPlugin } from '../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysDEGroupImpl extends PSModelObjectImpl implements IPSSysDEGroup {
  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get groupTag(): string {
    return this.M.groupTag;
  }

  get groupTag2(): string {
    return this.M.groupTag2;
  }

  get logicMode(): 'INITMODEL' | 'SYNCMODEL' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.logicMode;
  }

  get logicParam(): string {
    return this.M.logicParam;
  }

  get logicParam2(): string {
    return this.M.logicParam2;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psdegroupdetails: IPSDEGroupDetail[] | null = null;

  getPSDEGroupDetails(): IPSDEGroupDetail[] | null {
    if (this.psdegroupdetails == null) {
      this.psdegroupdetails = this.fillChildListModel(this.M.getPSDEGroupDetails, 'dataentity.IPSDEGroupDetail') as IPSDEGroupDetail[];
    }
    return this.psdegroupdetails;
  }

  get psDEGroupDetails(): IPSDEGroupDetail[] | null {
    return this.getPSDEGroupDetails();
  }

  findPSDEGroupDetail(objKey: any): IPSDEGroupDetail | null {
    return this.getPSModel5('dataentity.IPSDEGroupDetail', this.getPSDEGroupDetails(), objKey) as IPSDEGroupDetail;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysDEGroupImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSModelSortable' || cls == 'IPSObject' || cls == 'dataentity.IPSDEGroup' || cls == 'dataentity.IPSDataEntityObject' || cls == 'dataentity.IPSSysDEGroup')
      return true;
    return super.instanceof(cls);
  }
}
